import {message as Message} from 'ant-design-vue';
import ClipboardJS from "clipboard";

let clipboardSuccess = () => {
    Message.success('复制成功', 2000);
},clipboardError = () => {
    Message.error('复制失败', 2500);
};
const handleClipboard = (str: string, event: MouseEvent | TouchEvent) => {
    let clipboard = new ClipboardJS(event.target as Element, {
        text: () => str
    });
    clipboard.on('success', () => {
        clipboardSuccess();
        clipboard.destroy();
    })
    clipboard.on('error', () => {
        clipboardError();
        clipboard.destroy();
    });
    if (event instanceof MouseEvent) {
        (clipboard as any).onClick(event);
    }else {
        (clipboard as any).onTouchstart(event);
    }


}
